package text;

import java.io.*;
import java.util.Scanner;

public class test {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入姓名");
        String name = scanner.nextLine();
        System.out.println("请输入年龄");
        int age = scanner.nextInt();
        System.out.println("请输入性别");
        String gender = scanner.next();
        System.out.println("请输入个任描述");
        String desc = scanner.next();
        Person p = new Person(name,age,gender,desc);
        FileOutputStream fos = new FileOutputStream("person.obj");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(p);
        System.out.println("写入完毕");
        oos.close();

        FileInputStream fis = new FileInputStream("person.obj");
        BufferedInputStream bis = new BufferedInputStream(fis);
        ObjectInputStream ois = new ObjectInputStream(bis);
        Person p1 = (Person)ois.readObject();
        System.out.println(p1);
        ois.close();

    }
}
